package com.liit.controller.weixin.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liit.entity.PartyFormMap;
import com.liit.exception.WeixinException;
import com.liit.mapper.PartyMapper;
import com.liit.plugin.PageView;

/**
 * 
 * @author dingweibo
 * @Title: OrgPartyController.java
 * @Description: 机构活动
 * @date 2016年3月31日
 */
@Controller
@RequestMapping("/weixin/org/")
public class OrgPartyController extends WeixinBaseController {

	@Resource
	PartyMapper mapper;

	@ResponseBody
	@RequestMapping("party/findByPage")
	public PageView findByPage(String pageNow, String pageSize, String type) throws Exception {
		PartyFormMap partyFormMap = new PartyFormMap();
		String status = null;
		if ("pre".equals(type)) {
			status = "0,1,3";
		} else if ("done".equals(type)) {
			status = "2,4";
		} else {
			throw new WeixinException("参数异常");
		}
		partyFormMap.put("where", " orgInfoId=" + getWeixinUserInfo().get("orgInfoId") + " and status in (" + status + ")");
		partyFormMap.put("orderby", " order by createTime desc ");
		partyFormMap = toFormMap(partyFormMap, pageNow, pageSize, partyFormMap.getStr("orderby"));
		List<PartyFormMap> partyList = mapper.findByPage(partyFormMap);
		pageView.setRecords(partyList);
		return pageView;
	}
}